package com.zprmb.udzt.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zprmb.udzt.BbtApplication;
import com.zprmb.udzt.R;
import com.zprmb.udzt.bean.BankBean;
import com.zprmb.udzt.util.Constant;

public class BankAdapter extends BaseAdapter {
	private List<BankBean> list;
	private Context context;
	private String bankNo="1";
    
	public BankAdapter(List<BankBean> list, Context context, String bankNo) {
		super();
		this.list = list;
		this.context = context;
		this.bankNo = bankNo;
	} 

	public BankAdapter(List<BankBean> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Help h=null;
		if(convertView==null){
			h=new Help();
			convertView=LayoutInflater.from(context).inflate(R.layout.bank_item, null);
			h.img_bank=(ImageView)convertView.findViewById(R.id.img_bank);
			h.bank_info=(TextView)convertView.findViewById(R.id.bank_info);
			h.tv_name=(TextView)convertView.findViewById(R.id.bank_name);
			h.img_true=(ImageView)convertView.findViewById(R.id.img_true);
			convertView.setTag(h);
		}else{
		h=(Help) convertView.getTag();
		}
		BbtApplication.getInstance().display(Constant.URL+list.get(position).getLogoUrl(), h.img_bank);
		h.bank_info.setText(list.get(position).getTips());
		h.tv_name.setText(list.get(position).getBankName());
		
		if(bankNo.equals(list.get(position).getBankNameEn())){
			h.img_true.setVisibility(View.VISIBLE);
		}else{
			h.img_true.setVisibility(View.GONE);
		}
		return convertView;
	}
  class Help{
	  private ImageView img_bank;
	  private TextView bank_info,tv_name;
	  private ImageView img_true;
	
}
}
